package com.itheima.homework15;

import java.io.*;
import java.net.Socket;

public class Test09 {
    public static void main(String[] args) throws Exception {
        Socket socket=new Socket("127.0.1.0",10080);
        //读本地
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("C:\\Users\\hldn\\Desktop\\04内部类分类.png"));
        //网络中输出
        BufferedOutputStream bos=new BufferedOutputStream(socket.getOutputStream());
        //读服务器返回的信息
        BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        int b;
        while ((b=bis.read())!=-1){
            bos.write(b);
        }
        bos.flush();

        socket.shutdownOutput();//告知服务器数据写完了，给出一个结束标记

        String s = br.readLine();
        System.out.println("服务器返回："+s);
        bis.close();
        socket.close();
    }
}
